package com.company.Algorihm;

/**
 * @author VX5
 * @Title: MJC
 * @ProjectName DataStructure
 * @Description: TODO
 * @date ${DAT}22:38
 */
public class Hanoitower {
    public static void main(String[] args) {
        hanoiTower(4,'A','B','C');
    }
    public static void hanoiTower(int num,char a,char b,char c){
        if (num == 1){
            System.out.println("第1个盘从"+a+"->"+c);
        }else {
            hanoiTower(num-1,a,c,b);
            //把最下面的盘移动的轨迹输出便是每一步的解析
            System.out.println("第"+num +"个盘从"+a+"->"+c);//最下边的盘A-C
            hanoiTower(num - 1,b,a,c);//把B塔所有的盘从B-》C
        }
    }
}
